package com.example.quartzdemo.QuartzJob;

import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.time.LocalTime;

/**
 * TODO
 *
 * @ClassName QuartzOneJob
 * @Author xiaojiang
 * @Date 2021/11/12 下午 16:10
 */
public class QuartzOneJob extends QuartzJobBean {


    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //获取JobDetail中关联的数据
        System.out.println("---------------这是第一个定时---------------");
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        System.out.println("==1== " + String.valueOf(jobDetail));
        System.out.println("==2== " + String.valueOf(jobDetail.getJobBuilder()));
        System.out.println("==3== " + String.valueOf(jobDetail.getJobClass()));
        System.out.println("==4== " + String.valueOf(jobDetail.getDescription()));
        System.out.println("==5== " + String.valueOf(jobDetail.getKey()));
        System.out.println("==6== " + String.valueOf(jobDetail.getJobDataMap()));
        System.out.println("==7== " + String.valueOf(jobExecutionContext.getTrigger()));
        //String msg = (String) jobExecutionContext.getJobDetail().getJobDataMap().get("msg");
        String msg = String.valueOf(jobDetail.getJobDataMap().get("msg"));
        String Hello = String.valueOf(jobDetail.getJobDataMap().get("Hello"));
        System.out.println("==8== current time :" + LocalTime.now() + "---" + msg);
        System.out.println("==9== current time :" + LocalTime.now() + "---" + Hello);
        //System.out.println("current time :"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "---" + msg);

    }
}
